package dome_003;

/**
 * <p>Description: [synchronized关键字,对某个对象加锁]</p>
 * Created on 2020/12/3
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class Demo003_02 implements Runnable {

    private int count = 10;

    @Override
    public /*synchronized*/ void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count = " + count);
    }

    public static void main(String[] args) {
        Demo003_02 demo003_02 = new Demo003_02();
        for (int i = 0; i < 5; i++) {
            new Thread(demo003_02, "THREAD" + i).start();
        }
    }
}
